
<?php include_once 'common/header.php';  ?>
<!-- admin_main -->
<div class="admin_main">
	<!-- Admin_top end -->
	<?php include_once 'common/user_left.php';  ?>
	<!-- Admin_Left End -->
	<div class="admin_right">
		<div class="admin_right_title">
			<strong>资金管理</strong> &gt;&gt;  增加/扣除积分
		</div>
		<div class="admin_right_info">
			<form id="deductForm" name="deductForm" >
			<div class="admin_right_info_title"><h2>增加/扣除积分</h2></div>
			<ul>
				<li>
					<div class="admin_right_info_tr admin_right_info_l">用户名：</div>
					<div class="admin_right_info_tr admin_right_info_m">
					<input type="text" name="username" id="username" size="50"  />
					</div>
				</li>
				<li>
					<div class="admin_right_info_tr admin_right_info_l">积分：</div>
					<div class="admin_right_info_tr admin_right_info_m">
					<input type="text" name="available" id="available" size="50" />
					</div>
				</li>
				<li>
					<div class="admin_right_info_tr admin_right_info_l">积分类型：</div>
					<div class="admin_right_info_tr admin_right_info_m">
					<select name="type_id" id="type_id">
						<option value="0" selected="selected">所有</option>
						<?php foreach($creditTypeName as $key=>$value){?>
						<option value="<?php echo $key;?>" ><?php echo $value;?></option>
						<?php }?>
					</select>
					</div>
				</li>
				<li>
					<div class="admin_right_info_tr admin_right_info_l">变动类型：</div>
					<div class="admin_right_info_tr admin_right_info_m">
					<select name="op" id="op">
						<option value="0" selected="selected">所有</option>
						<?php foreach($creditOpName as $key=>$value){?>
						<option value="<?php echo $key;?>" ><?php echo $value;?></option>
						<?php }?>
					</select>
					</div>
				</li>
				
				<li>
					<div class="admin_right_info_tr admin_right_info_l">备注：</div>
					<div class="admin_right_info_tr admin_right_info_m">
					<input type="text" name="remark" id="remark" size="50" />
					</div>
				</li>
				<li>
					<input type="button" value="提交" onclick="deductsub()" />
				</li>
			</ul>
			</form>
			</div>
	</div>
<!-- Admin_Right End -->
</div>
<!-- admin_main end -->

<script type="text/javascript">
function deductsub(){
	var options = {
		url : '/ychadmin/credit/deduct/',
		clearForm :true,
		resetForm :true,
		beforeSubmit:  checkForm,
		dataType: "json",
		type:"post",
		success : function(ret) {
			if(ret.msg==''){
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				}); 
				$("#msg").html("操作成功");
			}else{
				$('#dialog').dialog({
					modal:true,
					title:'系统提示',
					buttons:{"确定":function(){$(this).dialog("close");}}
				}); 
				$("#msg").html(ret.msg);
			}
		}
	};
	$("#deductForm").ajaxSubmit(options);
	return false;
}

function checkForm(){
	var err = '';
	if($('#username').val()==''){
		err = '请填写有效的用户名';
	}else if(IsDouble($('#available').val())==false){
		err = '请填写有效的金额';
	}else if($('#type_id').val()==0){
		err = '请选择积分类型';
	}else if($('#op').val()==0){
		err = '请选择变动类型';
	}else if($('#remark').val()==''){
		err = '请填写备注';
	}
	if(err==''){
		return true;
	}else{
		$('#dialog').dialog({
			modal:true, //蒙层（弹出会影响页面大小）
			title:'系统提示',
			buttons:{"确定":function(){$(this).dialog("close");}}
		}); 
		$("#msg").html(err);
		return false;
	}
}
</script>

<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
</body>
</html>
